package com.cloud.log.kafka.consumer;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

@Component
public class LogConsumer {
	protected Logger logger = LoggerFactory.getLogger(LogConsumer.class);

    @KafkaListener(groupId = "testGroup",topics = "myTopic")
    public void listener1(ConsumerRecord<?, ?> cr) throws Exception {
        
        logger.info("testGroup_listener1 "+(String)cr.value());
    }
    
    @KafkaListener(groupId = "testGroup",topics = "myTopic")
    public void listener2(ConsumerRecord<?, ?> cr) throws Exception {
        
        logger.info("testGroup_listener2 "+(String)cr.value());
    }
    
    @KafkaListener(groupId = "logGroup",topics = "logTopic")
    public void logListener1(ConsumerRecord<?, ?> cr) throws Exception {
//        Thread.currentThread().getName()
        logger.info("logGroup_logListener1 "+(String)cr.value());
    }
}
